package top.healthylife.gateway.platform.bank.dto.personal.req;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import top.healthylife.gateway.dto.request.req.ApiReqDto;
import top.healthylife.gateway.platform.bank.dto.personal.PersonalQueryReason;

/**
 * @author : GaoZeXi
 * @date 2021/8/13 17:46
 */
@Data
@Accessors(chain = true)
@ApiModel("个人征信报告单笔查询")
public class BankReqPersonalCreditReportSingleDto extends ApiReqDto {
    @ApiModelProperty(value = "姓名", notes = "被查询用户姓名", required = true)
    private String name;
    @ApiModelProperty(value = "证件类型", notes = "被查询用户证件类型", required = true)
    private String certType;
    @ApiModelProperty(value = "证件号码", notes = "被查询用户证件号码", required = true)
    private String certNo;
    @ApiModelProperty(value = "查询原因", notes = "金融机构查询该消费者信用报告的原因（见附录：个人信用报告查询原因代码表）",dataType = "enum", required = true)
    private PersonalQueryReason queryReason;
    @ApiModelProperty(value = "查询版本", notes = "查询版本，预留字段，默认为0", required = false, hidden = true)
    private String reprotType;
    @ApiModelProperty(value = "返回模板类型", notes = "0：Html；1：Xml，2：Json", required = true)
    private String reportModelType;
    @ApiModelProperty(value = "查询基础段名", notes = "所要查询基础段名", required = false)
    private String tableName;
    @ApiModelProperty(value = "xml模板", notes = "http请求的xml模板", required = false,hidden = true)
    static String templateXMl = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"true\"?>\n" +
            "\n" +
            "-<rtdsRequest>\n" +
            "\n" +
            "<transCode>{transCode}</transCode>\n" +
            "<sysId>{sysId}</sysId>\n" +
            "<userId>{sysUserId}</userId>\n" +
            "<password>{sysPassword}</password>\n" +
            "<name>{name}</name>\n" +
            "<certType>{certType}</certType>\n" +
            "<certNo>{certNo}</certNo>\n" +
            "<queryReason>{queryReason}</queryReason>\n" +
            "<reportModelType>2</reportModelType>\n" +
            "</rtdsRequest>";

    @Override
    public String toString() {
        return StrUtil.format(templateXMl, BeanUtil.beanToMap(this));
    }

    public String getQueryReason() {
        return queryReason.getCode();
    }

}
